/*
 * @Author: new-wang
 * @Date: 2023-06-16 16:24:27
 * @LastEditors: new-wang
 * @LastEditTime: 2023-06-16 17:17:18
 * @Description: 加载views中vue文件生成路由数组 (未考虑嵌套路由) 
 */
const requireComponent = require.context("../../views", true, /.vue/);
let arr = [];
// console.log('keys', requireComponent.keys());  如：['./operate/index.vue']
requireComponent.keys().forEach(component => {

    let _keyarr = component.split('.')
    //component为获取到的vue文件 如'./operate/index.vue'
    //此处split分隔字符串 如 ['', '/operate/index', 'vue']

    const config = requireComponent(component);
    if (component.indexOf("index") != -1) {//有index看做即为首页
        arr.push({
            path: _keyarr[1],
            component: config.default,
            meta: {
                title: _keyarr[1].replace('/', '')
            }
        })
    } else {
        arr.push({
            path: _keyarr[1] + "/" + _keyarr[2],
            component: config.default,
            meta: {
                title: _keyarr[2]
            }
        })
    }
})
export default arr;